<?xml version="1.0" encoding="utf-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
  <start>
    <element name="library">
      <ref name="library-content"/>
    </element>
  </start>
  <define name="library-content">
    <oneOrMore>
      <element name="book">
        <ref name="book-content"/>
      </element>
    </oneOrMore>
  </define>
  <define name="book-content">
    <interleave>
      <attribute name="id"/>
      <attribute name="available"/>
      <element name="isbn">
        <ref name="isbn-content"/>
      </element>
      <element name="title">
        <ref name="title-content"/>
      </element>
      <zeroOrMore>
        <element name="author">
          <ref name="author-content"/>
        </element>
      </zeroOrMore>
      <zeroOrMore>
        <element name="character">
          <ref name="character-content"/>
        </element>
      </zeroOrMore>
    </interleave>
  </define>
  <define name="author-content">
    <attribute name="id"/>
    <element name="name">
      <ref name="name-content"/>
    </element>
    <element name="born">
      <ref name="born-content"/>
    </element>
    <optional>
      <element name="dead">
        <ref name="dead-content"/>
      </element>
    </optional>
  </define>
  <define name="born-content">
    <text/>
  </define>
  <define name="character-content">
    <attribute name="id"/>
    <element name="name">
      <ref name="name-content"/>
    </element>
    <element name="born">
      <ref name="born-content"/>
    </element>
    <element name="qualification">
      <ref name="qualification-content"/>
    </element>
  </define>
  <define name="dead-content">
    <text/>
  </define>
  <define name="isbn-content">
    <text/>
  </define>
  <define name="name-content">
    <text/>
  </define>
  <define name="qualification-content">
    <text/>
  </define>
  <define name="title-content">
    <attribute name="xml:lang"/>
    <text/>
  </define>
</grammar>
